# -*- coding: UTF-8 -*-
"a itchat momule"
__author__ = 'xiang'

import itchat, time

def send_msg(txts):
    itchat.auto_login(hotReload=True)
    dict_user = {}
    number = 1
    friendList = itchat.get_friends(update=True)[1:]

    for friend in friendList:
        nice=friend['DisplayName'] or friend['NickName']
        User=friend['UserName']
        temp_user={nice:User}
        dict_user.update(temp_user.items())
    try :
        print("准备发送微信好友,请稍后......\n")
        time.sleep(0.01)
        while number < 4 :
            input_name = input('请输入微信联系人昵称,非本人备注:')
            send_user=(dict_user.get(input_name))
            print(send_user)
            result=itchat.send(txts,send_user)
            print(result)
            number += 1
    except Exception as e :
        raise
